//
//  DHBuMember_CardCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/9.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHBuMember_CardCell.h"
#import "DHMemberCardView.h"

@interface DHBuMember_CardCell()

@property (strong, nonatomic) NSArray *arr;

@end

@implementation DHBuMember_CardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (NSArray *)arr{
    if (!_arr) {
        _arr = [NSArray array];
    }
    return _arr;
}

- (void)updateCellArr:(NSArray *)arr{
    self.arr = arr;
    
    [self.scrollView removeAllSubviews];
    self.scrollView.contentSize = CGSizeMake(self.arr.count * self.width, self.height);
    CGFloat space = (kScreenWidth - 182) / 2;
    [self.arr enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
        DHMemberCardView *card = [DHMemberCardView shareDHMemberCardView];
        card.frame = CGRectMake(kScreenWidth * idx + space , 20, 182, self.height - 40);
        if ([[obj objectForKey:@"name"] isEqualToString:@"租衣包月"]) {
            card.imgView.image = [UIImage imageNamed:@"month"];
        }else if ([[obj objectForKey:@"name"] isEqualToString:@"租衣季卡"]){
            card.imgView.image = [UIImage imageNamed:@"season"];
        }else if ([[obj objectForKey:@"name"] isEqualToString:@"租衣半年卡"]){
            card.imgView.image = [UIImage imageNamed:@"half_year"];
        }else if ([[obj objectForKey:@"name"] isEqualToString:@"租衣年卡"]){
            card.imgView.image = [UIImage imageNamed:@"year"];
        }
        card.nameLabel.text = [obj objectForKey:@"name"];
        [self.scrollView addSubview:card];
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
